package com.xintonghua.bussiness.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.base.SimpleBaseAdapter;
import com.xintonghua.bussiness.bean.AddProjectTypeBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者：wanxianyi
 * 时间：2018/3/31.
 * 包名：com.xintonghua.bussiness.adapter
 */

public class ShopLeftAdapter extends SimpleBaseAdapter<AddProjectTypeBean> {
    public ShopLeftAdapter(List<AddProjectTypeBean> list, Context context) {
        super(list, context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ShopLeftViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.adapter_add_list_product_type, null);
            holder = new ShopLeftViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ShopLeftViewHolder) convertView.getTag();

        }
        holder.tvTitle.setText(mList.get(position).getName());
        if (mList.get(position).isCheck()) {
            holder.tvTitle.setSelected(true);
            holder.tvTitle.setPressed(true);
            holder.linLay.setBackgroundResource(R.color.white);
        } else {
            holder.tvTitle.setSelected(false);
            holder.tvTitle.setPressed(false);
            holder.linLay.setBackgroundResource(R.color.grey_bg);
        }
        return convertView;
    }

    static class ShopLeftViewHolder {
        @BindView(R.id.tv_title)
        TextView tvTitle;
        @BindView(R.id.lin_lay)
        LinearLayout linLay;

        public ShopLeftViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
